//
//  Emotion.swift
//  EmotionKeyboard
//
//  Created by 史亚洲 on 16/1/27.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class Emotion: NSObject {
    
    //分组表情的文件
    var id: String?
    
    //表情文字
    var chs: String?
    
    //表情图片名称
    var png: String? {
        didSet {
            //一个模型只需要计算一次
            //给imagePath赋值
            
            if let bundleId=id,imageName=png {
           imagePath = NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + "\(bundleId)/" + "\(imageName)"
                //id后面没有文件路径啦,需要加上"/"
            }
            
        }
    }
    
    //图片绝对路径的属性,计算型属性,每次都需要计算
    var imagePath: String?
    
    //emoji表情的字符串,16进制的
    var code: String? {
        didSet {
            if let codeStr = code {
                emojiStr=codeStr.emojiStr()
            }
        }
    }
    
    
    var  emojiStr: String?
    
    
    //标记是否删除按钮
    var isDelete = false
    
    //标记是否空白表情的模型
    var isEmpty = false
    
    //添加删除按钮的构造方法
    init(isDelete: Bool) {
        self.isDelete = isDelete
        super.init()
    }
    
    //添加是否为空白表情的构造方法
    init(isEmpty: Bool) {
        self.isEmpty=isEmpty
        super.init()
    }
    

    
    init(id: String, dict: [String: String]) {
        self.id=id
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    //过滤key值
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    

    
    //重写对象的描述信息
    override var description: String {
        //kvc赋值,获取对象的字典信息
        let keys=["chs","png","code","id"]
        let dict=self.dictionaryWithValuesForKeys(keys)
        return dict.description
        
    
    
    }


}
